﻿namespace Digitalmes.Domain.Mes;

/// <summary>
/// 工艺路线明细项
/// </summary>
[SugarTable("proc_routing_item", "工艺路线项明细表")]
public class ProcRoutingItem : EntityBase
{
    /// <summary>
    /// 工艺路线 Id
    /// </summary>
    [SugarColumn(ColumnDescription = "工艺路线Id")]
    public long RoutingId { get; set; }

    /// <summary>
    /// 工艺路线编号
    /// </summary>
    [NotNull]
    [SugarColumn(ColumnDescription = "工艺路线编号", Length = 32)]
    public string? RoutingCode { get; set; }

    /// <summary>
    /// 工艺路线
    /// </summary>
    [Navigate(NavigateType.OneToOne, nameof(RoutingId))]
    public ProcRouting? Routing { get; set; }

    /// <summary>
    /// 工序 Id
    /// </summary>
    [SugarColumn(ColumnDescription = "工序Id")]
    public long ProcessId { get; set; }

    /// <summary>
    /// 工序编号
    /// </summary>
    [NotNull]
    [SugarColumn(ColumnDescription = "工序编号", Length = 32)]
    public string? ProcCode { get; set; }

    /// <summary>
    /// 工序
    /// </summary>
    [NotNull]
    [Navigate(NavigateType.OneToOne, nameof(ProcessId))]
    public ProcProcess? Process { get; set; }

    /// <summary>
    /// 标准加工工时（秒）
    /// </summary>
    [SugarColumn(ColumnDescription = "标准加工工时(秒)")]
    public double StdOpDuration { get; set; }

    /// <summary>
    /// 标准准备工时（秒）
    /// </summary>
    [SugarColumn(ColumnDescription = "标准准备工时(秒)")]
    public double StdPrepDuration { get; set; }

    /// <summary>
    /// 顺序号
    /// </summary>
    [SugarColumn(ColumnDescription = "顺序号")]
    public int Pos { get; set; }

    /// <summary>
    /// 进站时校验上一工序动作（不校验/上一站已完工/已完工且OK过站）
    /// </summary>
    /// <remarks>若上一个工序是可选项，会校验上上一个工序，依此类推。</remarks>
    [SugarColumn(ColumnDescription = "校验上一工序动作")]
    public PolicyCheckPrevProcEnum PolicyCheckPrevProc { get; set; }

    /// <summary>
    /// 过程中校验生产BOM动作（每次扫码校验/过站统一校验）
    /// </summary>
    [SugarColumn(ColumnDescription = "校验生产BOM动作")]
    public PolicyCheckProcBomEnum PolicyCheckProcBom { get; set; }

    /// <summary>
    /// 工艺校验策略。
    /// </summary>
    /// <remarks>策略数据采用 int32 位图存储，允许多个。</remarks>
    [SugarColumn(ColumnDescription = "工艺校验策略")]
    public PolicyCheckProcessEnum PolicyCheckProcess { get; set; }

    /// <summary>
    /// 工艺管控属性
    /// </summary>
    [SugarColumn(ColumnDescription = "工艺管控属性")]
    public ProcCtlAttrEnum CtlAttr { get; set; }

    /// <summary>
    /// 是否禁用
    /// </summary>
    [SugarColumn(ColumnDescription = "是否禁用")]
    public bool IsDisabled { get; set; }
}
